package com.hnyc.goods.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hnyc.goods.domain.GoodsOnline;
import com.hnyc.goods.service.IGoodsOnlineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * goods-onlineController
 * 
 * @author zero
 * @date 2023-03-10
 */
@RestController
@RequestMapping("/goods/goodsOnline")
public class GoodsOnlineController extends BaseController
{
    @Autowired
    private IGoodsOnlineService goodsOnlineService;

    /**
     * 查询goods-online列表
     */
    @PreAuthorize("@ss.hasPermi('goods:goodsOnline:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsOnline goodsOnline)
    {
        startPage();
        List<GoodsOnline> list = goodsOnlineService.selectGoodsOnlineList(goodsOnline);
        return getDataTable(list);
    }

    /**
     * 导出goods-online列表
     */
    @PreAuthorize("@ss.hasPermi('goods:goodsOnline:export')")
    @Log(title = "goods-online", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsOnline goodsOnline)
    {
        List<GoodsOnline> list = goodsOnlineService.selectGoodsOnlineList(goodsOnline);
        ExcelUtil<GoodsOnline> util = new ExcelUtil<GoodsOnline>(GoodsOnline.class);
        util.exportExcel(response, list, "goods-online数据");
    }

    /**
     * 获取goods-online详细信息
     */
    @PreAuthorize("@ss.hasPermi('goods:goodsOnline:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(goodsOnlineService.selectGoodsOnlineById(id));
    }

    /**
     * 新增goods-online
     */
    @PreAuthorize("@ss.hasPermi('goods:goodsOnline:add')")
    @Log(title = "goods-online", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsOnline goodsOnline)
    {
        return toAjax(goodsOnlineService.insertGoodsOnline(goodsOnline));
    }

    /**
     * 修改goods-online
     */
    @PreAuthorize("@ss.hasPermi('goods:goodsOnline:edit')")
    @Log(title = "goods-online", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsOnline goodsOnline)
    {
        return toAjax(goodsOnlineService.updateGoodsOnline(goodsOnline));
    }

    /**
     * 删除goods-online
     */
    @PreAuthorize("@ss.hasPermi('goods:goodsOnline:remove')")
    @Log(title = "goods-online", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(goodsOnlineService.deleteGoodsOnlineByIds(ids));
    }
}
